/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.sistemas.sse.entity;

import java.io.Serializable;
import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.annotations.Proxy;

/**
 *
 * @author laptop-w8
 */
@Entity
@Table(name = "TDEP")
@Proxy(lazy = false)
public class UbigeoDepartamento implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "CDEP")
    private long idDepartamento;
    @Column(name = "DCOD_DEP")
    private String dCodigo;
    @Column(name = "DNM_DEP")
    private String dNombre;
    @OneToMany(cascade = CascadeType.PERSIST, mappedBy = "departamento")
    private Set<UbigeoProvincia> provincias;

    public long getIdDepartamento() {
        return idDepartamento;
    }

    public void setIdDepartamento(long idDepartamento) {
        this.idDepartamento = idDepartamento;
    }

    public String getdCodigo() {
        return dCodigo;
    }

    public void setdCodigo(String dCodigo) {
        this.dCodigo = dCodigo;
    }

    public String getdNombre() {
        return dNombre;
    }

    public void setdNombre(String dNombre) {
        this.dNombre = dNombre;
    }

    public Set<UbigeoProvincia> getProvincias() {
        return provincias;
    }

    public void setProvincias(Set<UbigeoProvincia> provincias) {
        this.provincias = provincias;
    }

    
    public String toString(){
        return "id: "+this.dCodigo+" , nombre: "+this.dNombre;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (obj instanceof UbigeoDepartamento) {
            UbigeoDepartamento u1 = (UbigeoDepartamento) obj;
            return u1.getdCodigo().equals(this.dCodigo);
        }
        return false;
    }

}
